<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="./js/jquery.js"></script>
    <script src="./js/ajax.js"></script>
    <title>文件上传</title>
</head>

<body>
    <form id="uploadForm">
        <input type="file" name="avatar">
        <button type="submit" id="uploadBtn">上传</button>
    </form>

    <script>

        $("#uploadBtn").click(function (event) {
            event.preventDefault(); // 阻止表单的默认提交行为
            // 使用Ajax提交form数据
            $.ajax({
                url: 'http://localhost:3001/profile',
                type: 'POST',
                data: new FormData($("#uploadForm")[0]),
                processData: false,
                contentType: false,
                success: function (res) {
                    console.log(res.filePath);
                    const jsonData = 
                    ajax.get("/hello",jsonData, (data) => {
                        console.log(data);
                       
                    });
                    alert(1233);
                }
            })
        })
    </script>
</body>

</html>